package com.flame.shapeville.component.task1.shape2D;

import javafx.scene.paint.Color;
import javafx.scene.shape.Polygon;

/**
 * Represents a regular octagon used in Task 1.
 * <p>
 * This class draws an eight-sided polygon with equal side lengths.
 *
 * @author Flame Dev Team
 * @version 1.0
 * @since 2025-05-12
 */
public class JfOctagon extends JfShape2D {

    /**
     * Constructs a new octagon with the specified size.
     *
     * @param size the bounding box size for the octagon
     */
    public JfOctagon(double size) {
        this.size = size;
        double x1 = size / 2 - size / 2 / Math.sqrt(2);
        double x2 = size / 2 + size / 2 / Math.sqrt(2);
        double y1 = x1;
        double y2 = x2;
        shape = new Polygon(
                size / 2, 0,
                x1, y1,
                0, size / 2,
                x1, y2,
                size / 2, size,
                x2, y2,
                size, size / 2,
                x2, y1
        );
        initBaseParams(Color.CYAN);
    }
}
